function get(url, callback){
	var xhr;
	if( window.XMLHttpRequest ){
		xhr = new XMLHttpRequest();
	}else{
		xhr = new ActiveXObject("Msxml2.XMLHTTP");
	}
	xhr.open("GET", url, true);
	xhr.send();
	xhr.onreadystatechange = function(){
		if( xhr.readyState==4 && xhr.status==200 ){
			if( callback ){
				callback( xhr.responseText );
			}
		}
	}
}

function post(url, data, callback){
	var xhr;
	if( window.XMLHttpRequest ){
		xhr = new XMLHttpRequest();
	}else{
		xhr = new ActiveXObject("Msxml2.XMLHTTP");
	}
	xhr.open("POST", url, true);
	xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	xhr.send(data);
	xhr.onreadystatechange = function(){
		if( xhr.readyState==4 && xhr.status==200 ){
			if( callback ){
				callback( xhr.responseText );
			}
		}
	}
}


//promise
function promise_get(url){
	var promise=new Promise(function(success,error){//new一个promise进行函数
		get (url,function(str){//get 路径   
			success(str);//吧进行时改成完成时
		});
	});return promise;
}



//josnp 服务器script
function jsonp(url){
	var script = document.createElement("script");//创建一个script
	document.getElementsByTagName("head")[0].appendChild(script);//在页面上获取head在下面添加script
	script.src = url;//script的路径
}	
